package com.yunhe.java.day05;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by Administrator on 2017/7/25 0025.
 */
public class ArrOne {
    public static void main(String[] args) {

       int [] b=demoN();
//       for(int a:b){
//           System.out.println(a+" ");
//       }
        System.out.println(Arrays.toString(b));
    }
     public static int[] demoN() {
         int[] arr = new int[3];
         int count = 0;
         int sum =0;
         Scanner sc = new Scanner(System.in);
         while (true) {
             System.out.print("请输入第" + (count + 1) + "个数(输入-1结束输入):");
             int n = sc.nextInt();
             if (count == arr.length) {
                 arr = Kuorong(arr);
             }
             arr[count] = n;
             sum+=arr[count];
             count++;
             if (n < 0) {
                 break;
             }

         }
         System.out.println("和:"+(sum+1));
//         System.out.println(Arrays.toString(arr));
         int index= Arr.suoYin(arr,-1);
         int [] rsArr= new int[index];
         for (int i=0;i<rsArr.length;i++){
           rsArr [i] = arr[i];
         }
         return rsArr;
     }
//    public static int  suoYin(int [] arr2) {
//        int index = -1;
//        int n = 0;
//        for (int i = 0; i < arr2.length; i++) {
//
//            if (arr2[i] == 3) {
//                index = i;
//            }
//            return index;
//        }


      public static int[] Kuorong(int[] arr){
         int [] arr1=new int[arr.length*2];
         for(int i=0;i<arr.length;i++){
             arr1[i]=arr[i];
         }
        return arr1;
      }
}
